package com.example.fitnessservice.module.dao.usermapper;

import com.example.fitnessservice.module.pojo.MemberPurchaseOrder;
import com.example.fitnessservice.module.pojo.UserMember;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface MemberMapper {
    //根据用户id查看用户的会员信息
    @Select("select * from user_member where user_id = #{userId}")
    public UserMember findVipInformationById(Integer userId);

    //根据用户id修改用户的会员状态
    @Update("update user_member set member_status = 0 where user_id = #{userId}")
    public int updateMemberStatus(Integer userId);

    //修改会员的起始时间
    @Update("update user_member set start_time = #{startTime}, end_time = #{endTime}, member_status = 1 where user_id = #{userId}")
    public int updateMemberTime(UserMember userMember);

    @Insert("insert into user_member values (null, #{user_id}, #{startTime}, #{endTime}, 1")
    public int addMember(UserMember userMember);

    @Insert("insert into member_purchase_order values (null, #{userId}, #{orderTime}, #{orderStatus}, #{memberType}, #{money})")
    public int addMemberOrder(MemberPurchaseOrder memberPurchaseOrder);
}
